package com.csce.domain.entity.go_score.dto;

import com.csce.domain.entity.go_score.GoScoreExamPlace;
import com.csce.domain.entity.go_score.GoScoreExamStudent;
import com.doudou.core.container.ListUtil;
import lombok.*;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

/**
 * 妇产科考试-考场对象 go_score_exam_place
 *
 * @author zzx
 * @since 2024-05-17
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@ToString
public class GoScoreExamPlaceDto implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    private Long id;

    /**
     * 考试编号
     */
    private Long examId;

    /**
     * 考站编号
     */
    @NotNull(message = "考站不可为空")
    private Long placeId;

    /**
     * 教师编号集合
     */
    @NotEmpty(message = "教师不可为空")
    private List<Long> teacherIds;

    /**
     * 技能编号
     */
    @NotNull(message = "技能不可为空")
    private Long skillId;

    /**
     * 评分表集合
     */
    @NotEmpty(message = "评分表不可为空")
    private List<Long> sheetIds;

    @NotEmpty(message = "学员列表不可为空")
    private List<Long> studentIdList;


    public GoScoreExamPlace convertGoScoreExamPlace(){
        GoScoreExamPlace goScoreExamPlace = new GoScoreExamPlace();
        goScoreExamPlace.setPlaceId(this.placeId);
        goScoreExamPlace.setTeacherIds(ListUtil.toSimpleStr(this.teacherIds));
        goScoreExamPlace.setSkillId(this.skillId);
        goScoreExamPlace.setSheetIds(ListUtil.toSimpleStr(this.sheetIds));
        List<GoScoreExamStudent> goScoreExamStudentListUtil = ListUtil.linkedList();
        if (ListUtil.isNotEmpty(this.studentIdList)){
            for (Long userId : this.studentIdList) {
                GoScoreExamStudent goScoreExamStudent = new GoScoreExamStudent();
                goScoreExamStudent.setUserId(userId);
                goScoreExamStudentListUtil.add(goScoreExamStudent);
            }
        }
        goScoreExamPlace.setGoScoreExamStudentList(goScoreExamStudentListUtil);
        return goScoreExamPlace;
    }
}
